---
title: "Iran - Hebrew"
author: "`r Sys.info()['user']`"
date: "`r format(Sys.time(), '%Y-%m-%d')`"
output: html_document
---

# Compare Haaretz and Yedioth

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.width = 10, fig.height = 5)
source("functions.R")
dat <- cbind(readRDS("data_lss_he.RDS"), readRDS("data_newsmap_he.RDS"))
dat <- subset(dat, class %in% c("ir", "il"))
events <- yaml::read_yaml("events.yml")
```

```{r}
plot_volume(dat, "haaretz", col = color[2], ylim = c(0, 5))
plot_volume(dat, "yedioth", col = color[1], add = TRUE)
add_events(c(events$IL$military, events$IL$diplomacy), margin = 0.15)
legend("topleft", c("Haaretz", "Yedioth"), 
       col = color[2:1], lty = 1, lwd = 2, horiz = TRUE)
```

```{r}
tb <- table(dat$date, dat$publication)
cor(tb)
```

```{r}
par(mar = c(2.1, 4.1, 1.1, 1.1))
plot(dat$date, dat$lss, col = rgb(0, 0, 0, 0.1), 
     pch = 16, ylim = c(-2, 2), ylab = "Threat emphasis",
     xlim = as.Date(c("2009-01-01", "2018-12-31")))
abline(h = 0)
add_events(c(events$IL$military, events$IL$diplomacy))
```
```{r}
plot_loess(dat, dat$publication == "haaretz", span = 0.1, col = color[2],
           ylab = "Threat emphasis")
plot_loess(dat, dat$publication == "yedioth", span = 0.1, col = color[1], add = TRUE)
add_events(c(events$IL$diplomacy, events$IL$military))
abline(h = 0)
legend("bottomleft", c("Haaretz", "Yedioth"), 
       col = color[2:1], lty = 1, lwd = 2, horiz = TRUE)
```

```{r}
plot_loess(dat, dat$class == "il", span = 0.1, col = color[3],
           ylab = "Threat emphasis")
plot_loess(dat, dat$class == "ir", span = 0.1, col = color[4], add = TRUE)
abline(h = 0)
add_events(c(events$IL$legislation, events$IL$election))
legend("bottomleft", c("Israel", "Iran"), 
       col = color[3:4], lty = 1, lwd = 2, horiz = TRUE)
```
